import org.softmed.reflection.utils.ReflectionUtil;
import org.softmed.persistence.PersistenceManager;
import org.softmed.persistence.PersistenceManagerProvider;
import org.softmed.reflection.utils.FieldInfo;

private void recursiveDelete(Object object, PersistenceManager psutil,
		List<Object> deletedObjects, ReflectionUtil util) throws Throwable {
	if (deletedObjects.contains(object))
		return;
	deletedObjects.add(object);

	List<FieldInfo> fields = util.getNonNativeFieldInfos(object.getClass());
	for (FieldInfo fieldInfo : fields) {
		Object child = fieldInfo.getGetter().invoke(object, null);
		if (child == null)
			continue;
		if (List.class.isAssignableFrom(fieldInfo.getType())) {
			Class listType = util.isSpecificList(util.getField(object
					.getClass(), fieldInfo.getName()));
			if (listType == null)
				continue;

			List list = (List) child;
			for (Object listChild : list) {
				psutil.delete(listChild);
				recursiveDelete(listChild, psutil, deletedObjects, util);
			}

		} else {
			psutil.delete(child);
			recursiveDelete(child, psutil, deletedObjects, util);
		}
	}
}

all = queryParameters.getFirst("all");
if (all != null) {
		ReflectionUtil rutil = new ReflectionUtil();
		List<Object> deletedObjects = new ArrayList<Object>();
		recursiveDelete(object, util, deletedObjects, rutil);
}

util.delete(object);